﻿
Option Strict Off
Option Explicit On

Imports System
Imports System.Globalization

Public Class frmInital

    Private cFactoryInfo As New clsDbFactoryInfo
    Private m_szIPadr(4) As String
    Protected htMsgMst As New Hashtable
    Protected m_cData As New clsDbCondData 'ADD 苗 2018/1/27
    Private m_cEquipMat As clsDbEquipMat 'ADD 苗 2018/4/2
    Private m_DbIdoHyo As clsDbIdoHyo 'ADD 苗 2018/4/2

    '******************************************************************************
    '*  フォームロード処理
    '******************************************************************************
    Private Sub frmInital_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer

        Dim scrn As Screen = Screen.FromControl(Me)
        '>>20171109 兪
        If Me.WindowState = FormWindowState.Minimized Then
            Me.WindowState = FormWindowState.Normal
        End If
        '<<20171109 兪
        Me.Left = CInt((scrn.Bounds.Width - Me.Width) / 2)
        Me.Top = CInt((scrn.Bounds.Height - Me.Height) / 2)

        '言語の選択
        g_NlsLanguage = Trim(CultureInfo.CurrentCulture.ToString())

        i = GetKeyState(&H10)
        If -127 = i Or -128 = i Then     'VK_SHIFT = &H10 VK_CONTROL = &H11
            g_NlsLanguage = LANG_CHINESE
        End If

        'イニシャルファイル情報取得
        g_szInitFileName = My.Application.Info.DirectoryPath & "\SF.ini"
        LoadInitialInfo()

        g_fDBconnect = False
        g_iDBconnResult = 0


        'タイマ開始処理
        IntDBTimer.Interval = 100
        IntDBTimer.Enabled = True

        'If String.IsNullOrEmpty(g_CURRENT_EQUIP_ID) Then
        '    frmSetup.Show()
        'Else
        '    frmStartComplete.Show()
        '    Me.Width = 0
        '    Me.Height = 0
        'End If

    End Sub

    '******************************************************************************
    '*  フォームアンロード処理
    '******************************************************************************
    Private Sub frmMainMenu_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        'タイマ完了処理
        'IntTimer.Enabled = False

        'データベース切断
        DBacs.Disconnect()

        'イニシャルファイル情報保存
        SaveInitialInfo()

    End Sub

    '******************************************************************************
    '*  イニシャルファイル処理
    '******************************************************************************
    Private Sub LoadInitialInfo()

        'サーバー登録情報
        '>> 2018/02/22 安部 初期値変更
        'g_Server.szDrive = GetIniFile("SERVER", "DRIVE", "PostgreSQL ANSI", g_szInitFileName)
        'g_Server.szDrive = GetIniFile("SERVER", "DRIVE", "PostgreSQL Unicode", g_szInitFileName)
        g_Server.szDrive = GetIniFile("SERVER", "DRIVE", "orac-atlas", g_szInitFileName)
        '<< 2018/02/22 安部 初期値変更
        g_Server.szIPadr = GetIniFile("SERVER", "IP", "", g_szInitFileName)
        g_Server.szDsn = GetIniFile("SERVER", "DSN", "atlas", g_szInitFileName)
        g_Server.szDbn = GetIniFile("SERVER", "DBN", "atlas", g_szInitFileName)
        g_Server.szUid = GetIniFile("SERVER", "UID", "atlas", g_szInitFileName)
        g_Server.szPas = GetIniFile("SERVER", "PAS", "atlas", g_szInitFileName)
        g_Server.iOver = CInt(GetIniFile("SERVER", "OVER", "-1", g_szInitFileName))

        '>> 2018/02/20 安部 iniファイル整理
        'g_iMpcNo = CInt(GetIniFile("SERVER", "MPCNO", "0", g_szInitFileName))
        '<< 2018/02/20 安部 iniファイル整理

        g_CURRENT_EQUIP_ID = (GetIniFile("EQUIP", "EquipID", "", g_szInitFileName))
        g_CURRENT_EQUIP_TYPE = CInt((GetIniFile("EQUIP", "EquipType", "0", g_szInitFileName)))

        'MPC-通信モード
        'ADD MIAO 2019/12/22 BEGIN

        '設定内容は127.0.0.1の場合、本PCのIPを取得し、Iniファイルに設定する
        m_EquipIPAddress = GetIniFile("COMMUNICATION_MODE", "IP_ADDRESS", "0.0.0.0", g_szInitFileName)
        If m_EquipIPAddress = "0.0.0.0" Then
            Dim IPAdress As System.Net.IPAddress
            Dim str_IP As String
            Dim HostName As String
            HostName = System.Net.Dns.GetHostName ' 本PCのマシン名
            IPAdress = System.Net.Dns.GetHostEntry(HostName).AddressList.GetValue(1) '本PCのIP
            str_IP = IPAdress.ToString
            PutIniFile("COMMUNICATION_MODE", "IP_ADDRESS", str_IP, g_szInitFileName)
            m_EquipIPAddress = GetIniFile("COMMUNICATION_MODE", "IP_ADDRESS", "0.0.0.0", g_szInitFileName)
        End If
        'ADD MIAO 2019/12/22 END

        m_EquipPort = GetIniFile("COMMUNICATION_MODE", "PORT_NO", "0000", g_szInitFileName)
        If m_EquipPort = "0000" Then
            PutIniFile("COMMUNICATION_MODE", "PORT_NO", "8100", g_szInitFileName)
            m_EquipPort = GetIniFile("COMMUNICATION_MODE", "PORT_NO", "0000", g_szInitFileName)

        End If
        m_EquipInstPattern = GetIniFile("COMMUNICATION_MODE", "INSTRUCTION_PATTERN", "00", g_szInitFileName)
        m_EquipInstMode = GetIniFile("COMMUNICATION_MODE", "INSTRUCTION_MODE", "0", g_szInitFileName)
        m_WARNING = GetIniFile("COMMUNICATION_MODE", "WARNING", "1", g_szInitFileName)
        '>> 2018/02/20 DEL 安部 iniファイル整理
        'g_IS_PROD = CInt((GetIniFile("Envm", "IsHonban", "0", g_szInitFileName)))
        '<< 2018/02/20 DEL 安部 iniファイル整理

        ''ペーストDB接続用
        'paste_Server.szDrive = GetIniFile("PASTE_SERVER", "DRIVE", "SQL Server", g_szInitFileName)
        'paste_Server.szIPadr = GetIniFile("PASTE_SERVER", "IP", "192.168.60.233", g_szInitFileName)
        'paste_Server.szDsn = GetIniFile("PASTE_SERVER", "DSN", "", g_szInitFileName)
        'paste_Server.szDbn = GetIniFile("PASTE_SERVER", "DBN", "AgTest", g_szInitFileName)
        'paste_Server.szUid = GetIniFile("PASTE_SERVER", "UID", "sa", g_szInitFileName)
        'paste_Server.szPas = GetIniFile("PASTE_SERVER", "PAS", "svt060233", g_szInitFileName)
        'paste_Server.iOver = CInt(GetIniFile("PASTE_SERVER", "OVER", "-1", g_szInitFileName))

        ''金線DB接続用
        'wire_Server.szDrive = GetIniFile("WIRE_SERVER", "DRIVE", "SQL Server", g_szInitFileName)
        'wire_Server.szIPadr = GetIniFile("WIRE_SERVER", "IP", "192.168.60.233", g_szInitFileName)
        'wire_Server.szDsn = GetIniFile("WIRE_SERVER", "DSN", "", g_szInitFileName)
        'wire_Server.szDbn = GetIniFile("WIRE_SERVER", "DBN", "YXGL", g_szInitFileName)
        'wire_Server.szUid = GetIniFile("WIRE_SERVER", "UID", "sa", g_szInitFileName)
        'wire_Server.szPas = GetIniFile("WIRE_SERVER", "PAS", "svt060233", g_szInitFileName)
        'wire_Server.iOver = CInt(GetIniFile("WIRE_SERVER", "OVER", "-1", g_szInitFileName))

        ''insitetestDB接続用（週コード取得）
        'itinfra_Server.szDrive = GetIniFile("ITINFRA_SERVER", "DRIVE", "SQL Server", g_szInitFileName)
        'itinfra_Server.szIPadr = GetIniFile("ITINFRA_SERVER", "IP", "192.168.60.233", g_szInitFileName)
        'itinfra_Server.szDsn = GetIniFile("ITINFRA_SERVER", "DSN", "", g_szInitFileName)
        'itinfra_Server.szDbn = GetIniFile("ITINFRA_SERVER", "DBN", "insitetest", g_szInitFileName)
        'itinfra_Server.szUid = GetIniFile("ITINFRA_SERVER", "UID", "sa", g_szInitFileName)
        'itinfra_Server.szPas = GetIniFile("ITINFRA_SERVER", "PAS", "svt060233", g_szInitFileName)
        'itinfra_Server.iOver = CInt(GetIniFile("ITINFRA_SERVER", "OVER", "-1", g_szInitFileName))

        ''レジンDB接続用
        'resin_Server.szDrive = GetIniFile("RESIN_SERVER", "DRIVE", "SQL Server", g_szInitFileName)
        'resin_Server.szIPadr = GetIniFile("RESIN_SERVER", "IP", "192.168.60.233", g_szInitFileName)
        'resin_Server.szDsn = GetIniFile("RESIN_SERVER", "DSN", "", g_szInitFileName)
        'resin_Server.szDbn = GetIniFile("RESIN_SERVER", "DBN", "RSC_LPS", g_szInitFileName)
        'resin_Server.szUid = GetIniFile("RESIN_SERVER", "UID", "sa", g_szInitFileName)
        'resin_Server.szPas = GetIniFile("RESIN_SERVER", "PAS", "svt060233", g_szInitFileName)
        'resin_Server.iOver = CInt(GetIniFile("RESIN_SERVER", "OVER", "-1", g_szInitFileName))

    End Sub

    Private Sub SaveInitialInfo()

        'サーバー登録情報
        PutIniFile("SERVER", "DRIVE", g_Server.szDrive, g_szInitFileName)
        PutIniFile("SERVER", "IP", g_Server.szIPadr, g_szInitFileName)
        PutIniFile("SERVER", "DSN", g_Server.szDsn, g_szInitFileName)
        PutIniFile("SERVER", "DBN", g_Server.szDbn, g_szInitFileName)
        PutIniFile("SERVER", "UID", g_Server.szUid, g_szInitFileName)
        PutIniFile("SERVER", "PAS", g_Server.szPas, g_szInitFileName)
        PutIniFile("SERVER", "OVER", CStr(g_Server.iOver), g_szInitFileName)
        PutIniFile("SERVER", "PORT", CStr(g_Server.iPORT), g_szInitFileName) 'ADD MIAO 2018/10/19

        '>> 2018/02/20 安部 iniファイル整理
        'PutIniFile("SERVER", "MPCNO", CStr(g_iMpcNo), g_szInitFileName)
        '<< 2018/02/20 安部 iniファイル整理

        PutIniFile("EQUIP", "EquipID", g_CURRENT_EQUIP_ID, g_szInitFileName)
        PutIniFile("EQUIP", "EquipType", g_CURRENT_EQUIP_TYPE.ToString, g_szInitFileName)

        '>> 2018/02/20 DEL 安部 iniファイル整理
        'PutIniFile("Envm", "IsHonban", g_IS_PROD.ToString, g_szInitFileName)
        '<< 2018/02/20 DEL 安部 iniファイル整理

        ''ペーストDBサーバー登録情報
        'PutIniFile("PASTE_SERVER", "DRIVE", paste_Server.szDrive, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "IP", paste_Server.szIPadr, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "DSN", paste_Server.szDsn, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "DBN", paste_Server.szDbn, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "UID", paste_Server.szUid, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "PAS", paste_Server.szPas, g_szInitFileName)
        'PutIniFile("PASTE_SERVER", "OVER", CStr(paste_Server.iOver), g_szInitFileName)

        ''金線DBサーバー登録情報
        'PutIniFile("WIRE_SERVER", "DRIVE", wire_Server.szDrive, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "IP", wire_Server.szIPadr, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "DSN", wire_Server.szDsn, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "DBN", wire_Server.szDbn, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "UID", wire_Server.szUid, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "PAS", wire_Server.szPas, g_szInitFileName)
        'PutIniFile("WIRE_SERVER", "OVER", CStr(wire_Server.iOver), g_szInitFileName)

        ''itinfraサーバー登録情報
        'PutIniFile("ITINFRA_SERVER", "DRIVE", itinfra_Server.szDrive, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "IP", itinfra_Server.szIPadr, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "DSN", itinfra_Server.szDsn, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "DBN", itinfra_Server.szDbn, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "UID", itinfra_Server.szUid, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "PAS", itinfra_Server.szPas, g_szInitFileName)
        'PutIniFile("ITINFRA_SERVER", "OVER", CStr(itinfra_Server.iOver), g_szInitFileName)

        ''レジンDBサーバー登録情報
        'PutIniFile("RESIN_SERVER", "DRIVE", resin_Server.szDrive, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "IP", resin_Server.szIPadr, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "DSN", resin_Server.szDsn, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "DBN", resin_Server.szDbn, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "UID", resin_Server.szUid, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "PAS", resin_Server.szPas, g_szInitFileName)
        'PutIniFile("RESIN_SERVER", "OVER", CStr(resin_Server.iOver), g_szInitFileName)


    End Sub

    ' 言語指定でメッセージを取得し，HashTableに積む
    '>> 2018/02/20 安部 iniファイル整理
    'Private Sub setAllErrMsg(ByVal lang As String)
    '    Dim m_cLotInfo As New clsDbLotInfo
    '    Dim dtMsgMst As DataTable = m_cLotInfo.GetAllMsg(lang)
    '    For Each dr In dtMsgMst.Rows
    '        With htMsgMst
    '            .Add(dr("MESSAGE_ID"), dr("MESSAGE"))
    '        End With
    '    Next

    'End Sub
    '<< 2018/02/20 安部 iniファイル整理

    '******************************************************************************
    '*  データベース接続 割り込みタイマ処理
    '******************************************************************************
    Private Sub IntDBTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IntDBTimer.Tick
        Dim szVer As String

        If False = g_fDBconnect And 0 = g_iDBconnResult Then
            If "" = g_Server.szIPadr Or "0.0.0.0" = g_Server.szIPadr Then
                PanelIPadr.Top = 60
                PanelIPadr.Left = 0
                PanelIPadr.Visible = True
                IntDBTimer.Enabled = False
            Else
                g_fDBconnect = True

                'データベース接続
                With g_Server
                    g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver)
                    '>> 2018/02/22 安部 失敗時再接続しない
                    'If 1 <> g_iDBconnResult Then
                    '    .szDrive = CStr(IIf("PostgreSQL" = .szDrive, "PostgreSQL ANSI", "PostgreSQL"))
                    '    g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver)
                    'End If
                    '<< 2018/02/22 安部 失敗時再接続しない
                End With

                If 1 = g_iDBconnResult Then
                    '拠点情報取得
                    g_szFactoryName = cFactoryInfo.GetFactoryName
                    g_iFactoryMode = cFactoryInfo.GetFactoryMode
                    g_szClientVersion = cFactoryInfo.GetIcTagSwVersion(g_CURRENT_EQUIP_TYPE)
                    g_ip = cFactoryInfo.GetFTPip 'ADD MIAOJF

                    'メッセージマスタ取得
                    '>> 2018/02/20 安部 iniファイル整理
                    m_fIcTagUsed = CBool(g_DBSFCommon.GetFactoryInfo_Str2(PARAM_ICTAGUSED, PARAM_ICTAGUSED_DEFAULT))
                    m_szPortName = g_DBSFCommon.GetFactoryInfo_Str2(PARAM_PORTNAME, PARAM_PORTNAME_DEFAULT)
                    ' Dim m_szLang As String = GetIniFile("Envm", "LANG", "J", g_szInitFileName)
                    'm_szLang = GetIniFile("Envm", "LANG", "J", g_szInitFileName)
                    m_szLang = g_DBSFCommon.GetFactoryInfo_Str2(PARAM_LANG, PARAM_LANG_DEFAULT)
                    '>> 2018/02/20 安部 iniファイル整理
                    setAllErrMsg(m_szLang)

                    '>> 2018/03/01 大賀 言語設定をt_factory_infoで指定するように修正
                    g_NlsLanguage = m_szLang
                    System.Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo(m_szLang)
                    System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo(m_szLang)
                    '<< 2018/03/01 大賀 言語設定をt_factory_infoで指定するように修正

                    '>> 2018/02/20 安部 iniファイル整理
                    'イメージパス取得
                    'm_szImagePath = GetIniFile("Envm", "ImagePath", "C\", g_szInitFileName)
                    m_szImagePath = g_DBSFCommon.GetFactoryInfo_Str2(PARAM_IMAGEPATH, PARAM_IMAGEPATH_DEFAULT)
                    '>> 2018/02/20 安部 iniファイル整理

                    '表題表示
                    With My.Application.Info
                        g_szApliVersion = Format(.Version.Major, "000") & "." & Format(.Version.Minor, "000") & "." & Format(.Version.Build, "000") & Format(My.Application.Info.Version.Major, "000") & "." & Format(My.Application.Info.Version.Minor, "000") & "." & Format(My.Application.Info.Version.Build, "000")
                        '>> 2018/02/20 安部 iniファイル整理
                        'If 0 < g_iMpcNo Then
                        '    'UPD 苗 2018/1/19 装置No.の対応
                        '    Me.Text = g_szFactoryName & " " & g_EQUIP_NO & "  Ver " & .Version.Major & "." & .Version.Minor & "." & .Version.Build & " (" & .Description & ")" & "  " & .CompanyName & " (MpcNo." & g_iMpcNo & ")" & "'" & g_NlsLanguage & "'"
                        'Else
                        '    'UPD 苗 2018/1/19 装置No.の対応
                        '<< 2018/02/20 安部 iniファイル整理

                        Me.Text = g_szFactoryName & " " & g_EQUIP_NO & "  Ver " & .Version.Major & "." & .Version.Minor & "." & .Version.Build & "." & .Version.Revision & " (" & .Description & ")" & "  " & .CompanyName & " '" & g_NlsLanguage & "'"

                        '>> 2018/02/20 安部 iniファイル整理
                        'End If
                        ' 2018/02/20 安部 iniファイル整理

                        szVer = .Version.Major.ToString("000") & "." & .Version.Minor.ToString("000") & "." & .Version.Build.ToString("000")
                    End With

                    '操作画面の有効化
                    lblConnect.Visible = False

                    'btnSetup.Visible = True
                    btnStartComplt.Visible = True
                    'btnSwap.Visible = True
                    btnRandomInspection.Visible = True
                    'btnPQC.Visible = True
                    btnDBCheck.Visible = True
                    btnMDCheck.Visible = True
                    If g_CURRENT_EQUIP_TYPE > 0 Then
                        btnStartComplt.Enabled = True
                        btnSwap.Enabled = True
                    End If

                    'Check Update
                    g_szClientVersion = cFactoryInfo.GetIcTagSwVersion(g_CURRENT_EQUIP_TYPE)
                    UpdateMe()
                End If
            End If
        End If

    End Sub

    ''' <summary>
    ''' 装置タイプ別の画面を表示する
    ''' </summary>
    Private Sub ShowWindow()
        Select Case g_CURRENT_EQUIP_TYPE
            Case DEF_ID_TAPE 'S311
                frmStartCompleteTape.Show()

            Case DEF_ID_DIESER 'S31
                frmStartCompleteDicing.Show()
            Case DEF_ID_TAPE_UV 'S313
                frmStartCompleteTapeUV.Show()
            Case DEF_ID_DIC_CHK 'A31
                frmStartCompleteDicCheck.Show()
            Case DEF_ID_DB 'S41
                frmStartCompleteDB.Show()
                'frmStartCompleteDBCheck.Show()

            Case DEF_ID_WB 'S42
                frmStartCompleteWB.Show()

            Case DEF_ID_MOLD 'A51
                frmStartCompleteMold.Show()

            Case DEF_ID_PLASMA 'S66
                frmStartCompletePlasma.Show()

            Case DEF_ID_MARK 'A54
                frmStartCompleteMark.Show()

            '固化--已由RSB自己研发的画面处理
            'Case DEF_ID_MOLD_AFC
            '    'UPD 苗 2018/1/26 ベークA801,A802,A806の装置タイプの更新
            '    frmStartCompleteDbBake.Show()
            'Case DEF_ID_DBAFC
            '    'UPD 苗 2018/1/26 ベークA801,A802,A806の装置タイプの更新
            '    frmStartCompleteDbBake.Show()
            'Case DEF_ID_MEKIAFC
            '    'UPD 苗 2018/1/27 ベークA801,A802,A806の装置タイプの更新
            '    frmStartCompleteDbBake.Show()
            'Case DEF_ID_MOLD_AFC
            '    'UPD 苗 2018/1/27 ベークA801,A802,A806の装置タイプの更新
            '    frmStartCompleteDbBake.Show()

            Case DEF_ID_MOLDQC
                frmStartCompletePlateCheck.Show()

            Case DEF_ID_PLATE 'S122、S121
                frmStartCompletePlateRSB.Show()

            Case DEF_ID_DAM_CUT 'A10
                frmStartCompleteDamCutMold.Show()

            Case DEF_ID_CUT 'A53
                frmStartCompleteCut.Show()

            Case DEF_ID_PLTGAIKAN 'A121、A122
                'frmStartCompletePlateCheck.Show()
                frmStartCompleteAutoPlateCheck.Show()
                'ADD 苗 2018/1/14 END
        End Select
    End Sub

    '******************************************************************************
    '*  サーバーＩＰアドレス設定処理
    '******************************************************************************
    Private Sub txtIPadr1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIPadr1.TextChanged

        If True = IsNumeric(txtIPadr1.Text) Then
            If 0 <= CInt(txtIPadr1.Text) And CInt(txtIPadr1.Text) <= 255 Then
                m_szIPadr(1) = Trim(txtIPadr1.Text)
                btnIPset.Enabled = CheckIP()
            End If
        End If

    End Sub

    Private Sub txtIPadr2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIPadr2.TextChanged

        If True = IsNumeric(txtIPadr2.Text) Then
            If 0 <= CInt(txtIPadr2.Text) And CInt(txtIPadr2.Text) <= 255 Then
                m_szIPadr(2) = Trim(txtIPadr2.Text)
                btnIPset.Enabled = CheckIP()
            End If
        End If

    End Sub

    Private Sub txtIPadr3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIPadr3.TextChanged

        If True = IsNumeric(txtIPadr3.Text) Then
            If 0 <= CInt(txtIPadr3.Text) And CInt(txtIPadr3.Text) <= 255 Then
                m_szIPadr(3) = Trim(txtIPadr3.Text)
                btnIPset.Enabled = CheckIP()
            End If
        End If

    End Sub

    Private Sub txtIPadr4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIPadr4.TextChanged

        If True = IsNumeric(txtIPadr4.Text) Then
            If 0 <= CInt(txtIPadr4.Text) And CInt(txtIPadr4.Text) <= 255 Then
                m_szIPadr(4) = Trim(txtIPadr4.Text)
                btnIPset.Enabled = CheckIP()
            End If
        End If

    End Sub

    Private Sub btnIPset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIPset.Click

        g_Server.szIPadr = m_szIPadr(1) & "." & m_szIPadr(2) & "." & m_szIPadr(3) & "." & m_szIPadr(4)
        PanelIPadr.Visible = False
        IntDBTimer.Enabled = True

    End Sub

    Private Function CheckIP() As Boolean

        If "" <> m_szIPadr(1) And "" <> m_szIPadr(2) And "" <> m_szIPadr(3) And "" <> m_szIPadr(4) And "" <> Trim(txtIPadr1.Text) And "" <> Trim(txtIPadr2.Text) And "" <> Trim(txtIPadr3.Text) And "" <> Trim(txtIPadr4.Text) Then
            CheckIP = True
        Else
            CheckIP = False
        End If

    End Function

    Private Sub btnStartComplt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartComplt.Click
        ShowWindow()
    End Sub

    '>>20171109 兪
    Private Sub btnSwap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSwap.Click
        'Dim szIePath As String
        'Dim szUrl As String

        'szIePath = GetIniFile("PROD_SWAP", "IE_PATH", """c:\Program Files\Internet Explorer\iexplore.exe""", g_szInitFileName)
        'szUrl = GetIniFile("PROD_SWAP", "URL", "http://172.29.200.64/cs/login.aspx", g_szInitFileName)

        'Shell(String.Format("{0} {1}?EquipID={2}", szIePath, szUrl, g_EQUIP_NO)) 'UPD 苗 2018/1/19 装置No.の対応

        'PutIniFile("PROD_SWAP", "IE_PATH", szIePath, g_szInitFileName)
        'PutIniFile("PROD_SWAP", "URL", szUrl, g_szInitFileName)
        'UPD 苗 2018/1/27 BEGIN

        'ADD 苗 2018/4/2 BEING
        m_DbIdoHyo = New clsDbIdoHyo
        m_DbIdoHyo.GetEquipInfoByID(g_CURRENT_EQUIP_ID)


        If m_DbIdoHyo.EquipInfo.szKouteiCD = PROC_CD_DBA Or m_DbIdoHyo.EquipInfo.szKouteiCD = PROC_CD_WBA Or m_DbIdoHyo.EquipInfo.szKouteiCD = PROC_CD_WBS Then
            '外部EXEを呼び出す
            Dim strPrcCD As String

            strPrcCD = m_DbIdoHyo.EquipInfo.szKouteiCD
            If strPrcCD = PROC_CD_WBS Then strPrcCD = PROC_CD_WBA
            Dim strRetStatus As String
            m_cEquipMat = New clsDbEquipMat
            'm_cEquipMat.killProcess(g_ETKitMangeMix_WCF_WIN) 'Process Kill'DEL MIAO 2018/8/22 BEGIN

            strRetStatus = frmStartCompleteBase.Execute_Command(m_DbIdoHyo.EquipInfo.szKouteiCD, EXEC_PG_TAG_CHNG_MTRL, strPrcCD, m_DbIdoHyo.EquipInfo.szEquipNo, "EMS")

            'ADD 苗 2018/4/2 END
        Else
            '外部EXEを呼び出す
            Dim ProgName As String
            Dim dtDefExec = m_cData.GetDefExec(COMMON_PROC_CD, EXEC_PG_TAG_CHNG_MTRL)
            If dtDefExec.Rows.Count > 0 Then
                '定義が存在する
                ProgName = dtDefExec.Rows(0)("COMMAND_LINE")
                If Not IsDBNull(dtDefExec.Rows(0)("COMMAND_OPTION")) Then
                    Shell(String.Format(ProgName & " " & dtDefExec.Rows(0)("COMMAND_OPTION"), m_DbIdoHyo.EquipInfo.szEquipNo, "", "")) 'UPD 苗 2018/4/2
                End If
            End If
            'UPD 苗 2018/1/27 END
        End If
    End Sub
    '<<20171109 兪

    Private Sub btnPQC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPQC.Click
        'frmStartCompletePQC.Show()
    End Sub

    Private Sub ToolStripMenuItemEquip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemEquip.Click

        Dim frmSet As New frmSetup
        frmSet.StartPosition = FormStartPosition.CenterParent
        frmSet.ShowDialog()
    End Sub

    Private Sub MenuItemIcTag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemIcTag.Click
        Dim frmIctag As New frmIcTagEditor
        frmIctag.StartPosition = FormStartPosition.CenterParent
        frmIctag.ShowDialog()
    End Sub

    'Private Sub MenuItemReader_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemReader.Click
    '    Dim frmReader As New frmSetTagReader
    '    frmReader.StartPosition = FormStartPosition.CenterParent
    '    frmReader.ShowDialog()
    'End Sub

    Private Sub MenuItemUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemUpdate.Click
        g_szClientVersion = cFactoryInfo.GetIcTagSwVersion()
        UpdateMe(False)
    End Sub

    Public Sub UpdateMe(Optional ByVal fCheckType As Boolean = True)
        Dim ProcId As Integer
        g_szClientVersion = cFactoryInfo.GetIcTagSwVersion(g_CURRENT_EQUIP_TYPE)
        If "" = g_szDBIpAddress Or "" = g_szClientVersion Or "000.000.000" = g_szClientVersion Then
            Exit Sub
        End If

        Dim szCurVer As String
        With My.Application.Info.Version
            szCurVer = String.Format("{0}.{1}.{2}", .Major, .Minor, .Build)
        End With

        If fCheckType Then
            If CheckVersion(szCurVer) Then
                'DEL 苗 2018/2/11 BGGIN
                '>>20171202 兪
                'If MsgBox(htMsgMst("MSG00037"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'ADD 苗 2018/1/29
                '    Exit Sub
                'End If
                '<<20171202 兪
                'DEL 苗 2018/2/11 END
                'MsgBox(htMsgMst("MSG00037")) 
                MsgBox(getMsgStr("MSG00037")) 'ADD 苗 2018/2/11 UPD Miao 2019/1/2
            Else
                Exit Sub
            End If
        End If

        Try
            '>>20171109 兪
            'ProcId = Shell("SF_Update.exe -C" & szCurVer & " -V" & g_szClientVersion & " -I" & g_szDBIpAddress, AppWinStyle.NormalFocus)'DEL MIAO 2018/1/1
            ProcId = Shell("SF_Update.exe -C" & szCurVer & " -V" & g_szClientVersion & " -I" & g_ip, AppWinStyle.NormalFocus) 'ADD MIAO 2018/1/1

            '<<20171109 兪
        Catch ex As System.IO.FileNotFoundException
            ProcId = 0
        End Try

        If 0 = ProcId Then
            '終了しない
            MsgBox(htMsgMst("MSG00029") & g_szDBIpAddress)
        Else
            '終了
            Me.Close()
        End If

    End Sub

    Private Function CheckVersion(ByVal szCurVer As String) As Boolean
        If String.IsNullOrEmpty(g_szClientVersion) Then
            Return False
        ElseIf String.IsNullOrEmpty(szCurVer) Then
            If IsNumeric(g_szClientVersion.Replace(".", "")) AndAlso CInt(g_szClientVersion.Replace(".", "")) > 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return CalcVersion(g_szClientVersion) > CalcVersion(szCurVer)
        End If
    End Function

    Private Function CalcVersion(ByVal szVer As String) As Long
        Dim szVerArr() As String = szVer.Split(CChar("."))
        Dim iVer As Long = 0
        For Each ver As String In szVerArr
            iVer = CLng(iVer * 10 ^ 3 + CInt(ver))
        Next
        CalcVersion = iVer
    End Function
    'ADD 苗 2018/4/13 BEGIN
    Private Sub MenuItemRackUpdate_Click(sender As Object, e As EventArgs) Handles MenuItemRackUpdate.Click
        Dim frmIctag As New frmIcTagEditor
        frmIctag.StartPosition = FormStartPosition.CenterParent
        frmIctag.RackUpdateFlg = 1
        frmIctag.ShowDialog()
    End Sub
    'ADD 苗 2018/4/13 END
    Private Sub 履歴検索ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MenuItemHistorySeach.Click
        Dim frm1 As New frmHistorySeach
        frm1.ShowDialog()
    End Sub

    '履歴検索画面表示
    Private Sub MenuItemSeach_Click(sender As Object, e As EventArgs) Handles MenuItemSeach.Click
        Dim frm1 As New frmHistory
        frm1.ShowDialog()
    End Sub

    'ラック履歴検索画面表示
    Private Sub MenuItemRackSeach_Click(sender As Object, e As EventArgs) Handles MenuItemRackSeach.Click
        Dim frm1 As New frmRackHistory
        frm1.ShowDialog()
    End Sub
    'ベーク設備Lotクリア
    Private Sub MenuItemBakeLotClear_Click(sender As Object, e As EventArgs) Handles MenuItemBakeLotClear.Click
        Dim frm1 As New FrmBakeLotClear
        frm1.ShowDialog()
    End Sub
    'ADD MIAO 2019/10/01 
    'ユーザ登録画面表示
    Private Sub MenuItemUserLogin_Click(sender As Object, e As EventArgs) Handles MenuItemUserLogin.Click
        Dim frmUserLogin As New FrmUserLogin
        'ユーザ登録画面を呼び出し
        frmUserLogin.ShowDialog()
    End Sub

    Private Sub TSMRandCheckMaster_Click(sender As Object, e As EventArgs) Handles TSMRandCheckMaster.Click
        Dim frmRCRM As New frmRandCheckRuleMaster
        frmRCRM.ShowDialog()
    End Sub

    Private Sub btnRandomInspection_Click(sender As Object, e As EventArgs) Handles btnRandomInspection.Click

        Dim frm1 As New frmRandomInspection
        '抜け取り検査画面を呼出
        frm1.ShowDialog()
    End Sub

    Private Sub btnDBCheck_Click(sender As Object, e As EventArgs) Handles btnDBCheck.Click
        frmStartCompleteDBCheck.Show()
    End Sub

    Private Sub btnMDCheck_Click(sender As Object, e As EventArgs) Handles btnMDCheck.Click
        frmStartCompleteMoldCheck.Show()
    End Sub

    Private Sub MenuItemMPCSet_Click(sender As Object, e As EventArgs) Handles MenuItemMPCSet.Click
        Dim frmMPC As New frmMpcEditor
        frmMPC.ShowDialog()

    End Sub


    'Private Sub menuInsertRackinfo_Click(sender As Object, e As EventArgs) Handles menuInsertRackinfo.Click
    '    Dim inr As New insertRackinfo
    '    inr.ShowDialog()
    'End Sub

    Private Sub menuWBRackEdit_Click(sender As Object, e As EventArgs) Handles menuWBRackEdit.Click
        Dim inr As New frmWBRackMng
        inr.ShowDialog()
    End Sub

    Private Sub tsmenuLogSearch_Click(sender As Object, e As EventArgs) Handles tsmenuLogSearch.Click
        Dim inr As New frmSearchLog
        inr.ShowDialog()
    End Sub
End Class